import { LAYOUT } from './constant'
const modules = import.meta.globEager('./modules/*.js')
const routes = Object.keys(modules).map(key => modules[key].default).flat()

const frameIn = [
  {
    path: '/',
    component: LAYOUT,
    redirect: { name: 'home' },
    children: [
      {
        path: 'home',
        name: 'home',
        meta: {
          title: '首页'
        },
        component: () => import('@/views/system/Home.vue')
      },
      {
        path: '401',
        name: '401',
        meta: {
          title: '401'
        },
        component: () => import('@/views/system/error/401.vue')
      },
      {
        path: '403',
        name: '403',
        meta: {
          title: '403'
        },
        component: () => import('@/views/system/error/403.vue')
      },
      {
        path: '404',
        name: '404',
        meta: {
          title: '404'
        },
        component: () => import('@/views/system/error/404.vue')
      }
    ]
  },
  { path: '/:pathMatch(.*)*', redirect: '/404', meta: { hidden: true } }
]

const frameOut = [
  {
    path: '/login',
    name: 'login',
    meta: { hidden: true },
    component: () => import('@/views/system/login/index.vue')
  }
]

export default [
  ...frameIn,
  ...routes,
  ...frameOut
]
